/**
 * 
 */
package de.cbf.cam.dsa.tavern.carte.ui;

import java.awt.event.ActionListener;
import java.util.Collection;
import java.util.Iterator;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;

import de.cbf.cam.dsa.tavern.carte.model.entities.Addendum;
import de.cbf.cam.dsa.tavern.carte.model.entities.Ingredient;
import de.cbf.cam.dsa.tavern.carte.model.entities.Processing;
import de.cbf.cam.dsa.tavern.carte.model.entities.interfaces.IEditableEntity;

/**
 * @author Stefan Alter
 *
 */
public class CompositeEditIngredient extends AbstractCompositeEditEntity {
	private CompositeEditIngredientData  compositeEditData;
	/**
	 * @param parent
	 * @param style
	 */
	public CompositeEditIngredient(Composite parent, int style) {
		super(parent, style);	
	}

	/* (non-Javadoc)
	 * @see de.cbf.cam.dsa.tavern.carte.ui.interfaces.ICompositeEditEntity#clear()
	 */
	@Override
	public void clear() {
		compositeEditData.clearData();
	}
	@Override
	public void setEnabled(boolean enabled) {
		compositeEditData.setEnabled(enabled);
		super.setEnabled(enabled);
	}
	/* (non-Javadoc)
	 * @see de.cbf.cam.dsa.tavern.carte.ui.AbstractCompositeEditEntity#checkEntity(de.cbf.cam.dsa.tavern.carte.model.entities.interfaces.IEditableEntity)
	 */
	@Override
	protected boolean checkEntity(IEditableEntity value) {
		if (value instanceof Ingredient) {
			return true;			
		}
		return false;
	}

	/* (non-Javadoc)
	 * @see de.cbf.cam.dsa.tavern.carte.ui.AbstractCompositeEditEntity#setEntityData(de.cbf.cam.dsa.tavern.carte.model.entities.interfaces.IEditableEntity)
	 */
	@Override
	protected void setEntityData(IEditableEntity value) {
		compositeEditData.setEntityData(value);
	}

	/* (non-Javadoc)
	 * @see de.cbf.cam.dsa.tavern.carte.ui.AbstractCompositeEditEntity#createCompositeEntity(org.eclipse.swt.widgets.Composite)
	 */
	@Override
	protected Composite createCompositeEntity(Composite parent) {
		compositeEditData = new CompositeEditIngredientData(parent, SWT.NONE); 
		return compositeEditData;
	}
	
//	=========================================
//		through to data composite
//	=========================================
	//Properties
	public String getIngredientName(){
		return compositeEditData.getIngredientName();
	}
	public void setIngredientName(String name){
		compositeEditData.setIngredientName(name);
	}
	
	public void setIngredientParent(Ingredient parent){
		compositeEditData.setIngredientParent(parent);
	}
	
	public void setCategoryTypes(Iterator<String> iterator){
		compositeEditData.setCategoryTypes(iterator);		
	}
	
	public boolean getIsIngredient(){
		return compositeEditData.getIsIngredient();
	}
	public void setIsIngredient(boolean ingredient){
		compositeEditData.setIsIngredient(ingredient);		
	}
	public boolean getIsCategory(){
		return compositeEditData.getIsCategory();
	}
	public void setIsCategory(boolean category){
		compositeEditData.setIsCategory(category);
	}
	
	public Double getPrice(){
		return compositeEditData.getPrice();		
	}
	public void setPrice(Double value){
		compositeEditData.setPrice(value);
	}
	public String getDescription(){
		return compositeEditData.getDescription();
	}
	
	public void setDescription(String value){
		compositeEditData.setDescription(value);
	}
	
	public Collection<String> getCounts(){
		return compositeEditData.getCounts();
	}

	public void setCounts(Iterator<String> iterator){
		compositeEditData.setCounts(iterator);
	}
	
	public Processing getSelectedAllProcessing(){
		return compositeEditData.getSelectedAllProcessing();
	}
	public int getSelectedAllProcessingIndex(){
		return compositeEditData.getSelectedAllProcessingIndex();
	}
	public void setSelectedAllProcessingIndex(int index){
		compositeEditData.setSelectedAllProcessingIndex(index);
	}
	
	public void setAllPossibleProcessings(Iterator<Processing> iterator){
		compositeEditData.setAllPossibleProcessings(iterator);
	}	
	public Collection<Processing> getPossibleProcessings() {
		return compositeEditData.getPossibleProcessings();
	}
	public void setPossibleProcessings(Iterator<Processing> iterator){
		compositeEditData.setPossibleProcessings(iterator);
	}
	public Processing getSelectedPossibleProcessing(){
		return compositeEditData.getSelectedPossibleProcessing();
	}	
	public int getSelectedPossibleProcessingIndex(){
		return compositeEditData.getSelectedPossibleProcessingIndex();
	}
	public void setSelectedPossibleProcessingIndex(int index){
		compositeEditData.setSelectedPossibleProcessingIndex(index);
	}
	public void setSelectedPossibleProcessingIndex(String text){
		compositeEditData.setSelectedPossibleProcessingIndex(text);
	}
	
	public void setPossibleAddendums(Iterator<Addendum> iterator){
		compositeEditData.setPossibleAddendums(iterator);
	}	
	public Addendum getSelectedAddendum(){
		return compositeEditData.getSelectedAddendum();
	}
	public int getSelectedAddendumIndex(){
		return compositeEditData.getSelectedAddendumIndex();
	}
	public void setSelectedAddendumIndex(int index){
		compositeEditData.setSelectedAddendumIndex(index);
	}
	
//		==================================
//			UI enable/disable
//		==================================
	public void setProcessingUI(boolean isIngredient) {
		compositeEditData.setProcessingUI(isIngredient);	
	}	
	public void setButtonToParentEnabled(boolean enabled){
		compositeEditData.setButtonToParentEnabled(enabled);
	}
	public void setButtonToCategoriesEnabled(boolean enabled){
		compositeEditData.setButtonToCategoriesEnabled(enabled);
	}
	public void setButtonAddProcessingEnabled(boolean enabled){
		compositeEditData.setButtonAddProcessingEnabled(enabled);
	}
	public void setButtonRemoveProcessingEnabled(boolean enabled){
		compositeEditData.setButtonRemoveProcessingEnabled(enabled);
	}
	public void setButtonAddAddendumEnabled(boolean enabled){
		compositeEditData.setButtonAddAddendumEnabled(enabled);
	}
	public void setButtonRemoveAddendumEnabled(boolean enabled){
		compositeEditData.setButtonRemoveAddendumEnabled(enabled);
	}
	public void setIngredientSetEnabled(boolean value){
		compositeEditData.setIngredientSetEnabled(value);
	}
	
//	====================
//		Listeners
//	====================	
	public boolean registerCountsModifiedListener(ActionListener listener){
		return compositeEditData.registerCountsModifiedListener(listener);
	}
	public boolean deRegisterCountsModifiedListener(ActionListener listener){
		return compositeEditData.deRegisterCountsModifiedListener(listener);
	}
	
	public boolean registerAddProcessingListener(ActionListener listener){
		return compositeEditData.registerAddProcessingListener(listener);
	}
	public boolean deRegisterAddProcessingListener(ActionListener listener){
		return compositeEditData.deRegisterAddProcessingListener(listener);
	}	
	
	public boolean registerRemoveProcessingListener(ActionListener listener){
		return compositeEditData.registerRemoveProcessingListener(listener);
	}
	public boolean deRegisterRemoveProcessingListener(ActionListener listener){
		return compositeEditData.deRegisterRemoveProcessingListener(listener);
	}
		
	public boolean registerPossibleProcessingSelectedListener(ActionListener listener){
		return compositeEditData.registerPossibleProcessingSelectedListener(listener);
	}
	public boolean deRegisterPossibleProcessingSelectedListener(ActionListener listener){
		return compositeEditData.deRegisterPossibleProcessingSelectedListener(listener);
	}
		
	public boolean registerAllProcessingSelectedListener(ActionListener listener){
		return compositeEditData.registerAllProcessingSelectedListener(listener);
	}
	public boolean deRegisterAllProcessingSelectedListener(ActionListener listener){
		return compositeEditData.deRegisterAllProcessingSelectedListener(listener);
	}
		
	public boolean registerAllProcessingsDoubleClickListener(ActionListener listener){
		return compositeEditData.registerAllProcessingsDoubleClickListener(listener);
	}
	public boolean deRegisterAllProcessingsDoubleClickListener(ActionListener listener){
		return compositeEditData.deRegisterAllProcessingsDoubleClickListener(listener);
	}
		
	public boolean registerAddAddendumListener(ActionListener listener){
		return compositeEditData.registerAddAddendumListener(listener);
	}
	public boolean deRegisterAddAddendumListener(ActionListener listener){
		return compositeEditData.deRegisterAddAddendumListener(listener);
	}
		
	public boolean registerRemoveAddendumListener(ActionListener listener){
		return compositeEditData.registerRemoveAddendumListener(listener);
	}
	public boolean deRegisterRemoveAddendumListener(ActionListener listener){
		return compositeEditData.deRegisterRemoveAddendumListener(listener);
	}
		
	public boolean registerAddendumSelectedListener(ActionListener listener){
		return compositeEditData.registerAddendumSelectedListener(listener);
	}
	public boolean deRegisterAddendumSelectedListener(ActionListener listener){
		return compositeEditData.deRegisterAddendumSelectedListener(listener);
	}
		
	public boolean registerParentChangedListener(ActionListener listener){
		return compositeEditData.registerParentChangedListener(listener);
	}
	public boolean deRegisterParentChangedListener(ActionListener listener){
		return compositeEditData.deRegisterParentChangedListener(listener);
	}
		
	public boolean registerDeleteParentListener(ActionListener listener){
		return compositeEditData.registerDeleteParentListener(listener);
	}
	public boolean deRegisterDeleteParentListener(ActionListener listener){
		return compositeEditData.deRegisterDeleteParentListener(listener);
	}
		
	public boolean registerCategoriesChangedListener(ActionListener listener){
		return compositeEditData.registerCategoriesChangedListener(listener);		
	}
	public boolean deRegisterCategoriesChangedListener(ActionListener listener){
		return compositeEditData.deRegisterCategoriesChangedListener(listener);
	}
		
	public boolean registerDeleteLastCategoryListener(ActionListener listener){
		return compositeEditData.registerDeleteLastCategoryListener(listener);
	}
	public boolean deRegisterDeleteLastCategoryListener(ActionListener listener){
		return compositeEditData.deRegisterDeleteLastCategoryListener(listener);
	}
		
	public boolean registerNowIngredientListener(ActionListener listener){
		return compositeEditData.registerNowIngredientListener(listener);
	}
	public boolean deRegisterNowIngredientListener(ActionListener listener){
		return compositeEditData.deRegisterNowIngredientListener(listener);
	}
		
	public boolean registerNowCategoryListener(ActionListener listener){
		return compositeEditData.registerNowCategoryListener(listener);
	}
	public boolean deRegisterNowCategoryListener(ActionListener listener){
		return compositeEditData.deRegisterNowCategoryListener(listener);
	}
		
	public boolean registerNameModifiedListener(ActionListener listener){
		return compositeEditData.registerNameModifiedListener(listener);
	}
	public boolean deRegisterNameModifiedListener(ActionListener listener){
		return compositeEditData.deRegisterNameModifiedListener(listener);
	}
		
	public boolean registerDescriptionModifiedListener(ActionListener listener){
		return compositeEditData.registerDescriptionModifiedListener(listener);
	}
	public boolean deRegisterDescriptionModifiedListener(ActionListener listener){
		return compositeEditData.deRegisterDescriptionModifiedListener(listener);
	}
	
	public boolean registerPriceModifiedListener(ActionListener listener){
		return compositeEditData.registerPriceModifiedListener(listener);
	}
	public boolean deRegisterPriceModifiedListener(ActionListener listener){
		return compositeEditData.deRegisterPriceModifiedListener(listener);
	}
	
}
